package com.myzombieapocalypse.projectz.application;

import com.myzombieapocalypse.projectz.domain.Account;
import com.myzombieapocalypse.projectz.domain.AccountDAO;
import com.myzombieapocalypse.projectz.web.forms.Registration;

import java.util.Date;

/**
 * User: StuartS
 * Date: 31/10/11
 * Time: 22:14
 */
public class RegisterFacadeTx implements RegisterFacade {

    private AccountDAO accountDAO;

    public AccountDAO getAccountDAO() {
        return accountDAO;
    }

    public void setAccountDAO(AccountDAO accountDAO) {
        this.accountDAO = accountDAO;
    }

    public void createAccount(Registration registration) {
        Account account = new Account();
        account.setCreateDate(new Date());
        account.setEmail(registration.getEmail());
        account.setPassword(registration.getPassword());
        account.setFirstName(registration.getFirstName());
        account.setLastName(registration.getLastName());
        saveAccount(account);
    }

    public void saveAccount(Account account) {
        accountDAO.save(account);
    }
}
